package com.qiezzi.eggplant.base;

import android.graphics.Bitmap;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.qiezzi.eggplant.R;


public abstract class BaseActivity extends FragmentActivity implements View.OnClickListener{

    //头部控件
    private TextView tv_main_title_left_return;
    private TextView tv_main_title_textview;
    private TextView tv_main_title_setting;
    private ImageView iv_right_view;
    private ImageView iv_left_view;
    private LinearLayout ll_left_layout;


    //初始化头部控件的方法
    public abstract void initHeader();

    //查找控件的方法
    public abstract void initWidget();
    //设置状态的方法
    public abstract void setWidgetState();

    //联网获取数据的方法
    public abstract void getData();



    //初始化头部控件
    public void inittHeaderWidget() {

        tv_main_title_left_return = (TextView) findViewById(R.id.id_tv_back);
        tv_main_title_textview = (TextView) findViewById(R.id.tv_main_title_textview);
        tv_main_title_setting = (TextView) findViewById(R.id.tv_main_title_setting);
        iv_right_view = (ImageView) findViewById(R.id.iv_right_view);
        iv_left_view = (ImageView) findViewById(R.id.iv_left_view);
        ll_left_layout = (LinearLayout) findViewById(R.id.ll_left_layout);

    }

    //左边的控件显示
    public void addBtnLeftListener(View.OnClickListener listener) {
        tv_main_title_left_return.setVisibility(View.VISIBLE);
        tv_main_title_left_return.setOnClickListener(listener);
    }

    //左边的图片空间显示
    public void addIMGLeftListener(View.OnClickListener listener){
        iv_left_view.setVisibility(View.VISIBLE);
        ll_left_layout.setOnClickListener(listener);
    }

    //右边文字控件
    public void addBtnRightListener(View.OnClickListener listener) {
        tv_main_title_setting.setVisibility(View.VISIBLE);
        tv_main_title_setting.setOnClickListener(listener);
    }

    //右边文字控件自定义文字内容
    public void addBtnRightTextListener(View.OnClickListener listener,String title) {
        tv_main_title_setting.setVisibility(View.VISIBLE);
        tv_main_title_setting.setOnClickListener(listener);
        tv_main_title_setting.setText(title);
    }

    //右边图片控件
    public void addIMGRightListener(View.OnClickListener listener) {
        iv_right_view.setVisibility(View.VISIBLE);
        iv_right_view.setOnClickListener(listener);
    }

    //右边图片控件自定义图片
    public void addIMGRightBitmapListener(View.OnClickListener listener,Bitmap bitmap) {
        iv_right_view.setVisibility(View.VISIBLE);
        iv_right_view.setOnClickListener(listener);
        iv_right_view.setImageBitmap(bitmap);
    }


    public void setTitle(String title) {//设置中间文字的内容
        tv_main_title_textview.setText(title);
    }

}
